package ch.usi.inf.pf2;

import ch.usi.inf.pf2.cell.Cell;

/**
 * @author Ebrisa Savina Mastrodicasa
 * @date April 18th, 2010
 */

/**
 * SpreadSheetPrinter class prints a minimal spreadsheet to the text terminal.
 */
public class SpreadSheetPrinter
{

    private Sheet sheet;

    /**
     * Construct a SpreadSheetPrinter that simulates a minimal spreadsheet
     * application.
     * 
     * @param sheet
     *            The sheet of the application.
     */
    public SpreadSheetPrinter(Sheet sheet)
    {
	   this.sheet = sheet;
    }

    /**
     * Print to the text terminal the initialized sheet.
     */
    public void print()
    {
	   Cell[][] gridToPrint = sheet.getGrid();
	   for (int i = 0; i < sheet.getRows(); i++)
	   {
		  for (int j = 0; j < sheet.getColumns(); j++)
		  {
			 System.out.print(gridToPrint[i][j]
				    .cutContentAccordingCellLength());
		  }
		  System.out.print("\n");
	   }
    }

}
